package cn.flaty.views.web.interceptors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.util.WebUtils;

import cn.flaty.views.web.WebConstants;

public class BaseInterceptor extends HandlerInterceptorAdapter {

	/* 
	 *  添加base上下文环境 
	 */
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		String base = request.getContextPath();
		request.setAttribute(WebConstants.WEB_CONTEXT_PATH,request.getScheme() + "://" + request.getServerName() + ":"
						+ request.getServerPort() + base);
		return true;
	}


}
